﻿package plugin.roleN.compoment
{
    import com.core.*;
    import com.sh.game.global.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import plugin.roleN.model.*;
    import uiresource.roleui.*;

    public class ArmItemCtrl extends ArmItemUI
    {
        public var Other:Boolean = false;
        private var clicktime:int = 0;
        public var baseicon:String = "";
        public var isOther:Boolean = false;
        private var _data:Object = null;

        public function ArmItemCtrl()
        {
            return;
        }// end function

        override protected function initializeView() : void
        {
            this.addEventListener(MouseEvent.CLICK, this.clickHandler);
            this.addEventListener(MouseEvent.ROLL_OVER, this.onOver);
            this.addEventListener(MouseEvent.MOUSE_OUT, this.onOut);
            item.mouseEnabled = false;
            item.mouseChildren = false;
            item.flagshow = false;
            return;
        }// end function

        protected function onOver(event:MouseEvent) : void
        {
            if (this.data == null)
            {
                return;
            }
            this.removeEventListener(MouseEvent.MOUSE_OVER, this.onOver);
            if (this.data.itemtype == 1)
            {
                ModelProxy.change("tips", "arm", {data:[this.data], p:new Point(GlobalLayer.instance.flashStage.mouseX, GlobalLayer.instance.flashStage.mouseY)});
            }
            return;
        }// end function

        protected function onOut(event:MouseEvent) : void
        {
            ModelProxy.change("tips", "state", "close");
            return;
        }// end function

        protected function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:Boolean = false;
            if (this.isOther)
            {
                return;
            }
            if (getTimer() - this.clicktime < 300)
            {
                this.clicktime = getTimer();
                if (this.Other)
                {
                    return;
                }
                if (this.data)
                {
                    _loc_2 = ModelProxy.getValue("data", "qhflag");
                    if (_loc_2)
                    {
                        ModelProxy.change("movetips", "error", "强化中不能脱装备");
                        return;
                    }
                    PluginManager.instance.sendToServer("role", CMDRole.TakeOff, this.data.pos);
                }
            }
            this.clicktime = getTimer();
            return;
        }// end function

        public function get data() : Object
        {
            return this._data;
        }// end function

        public function set data(param1:Object) : void
        {
            this._data = param1;
            this._data.wear = 1;
            var _loc_2:* = this.item.getChildByName("bg") as UrlImage;
            if (this.data == null)
            {
                this.item.data = {icon:this.baseicon};
                _loc_2.visible = false;
            }
            else if (!this._data.hasOwnProperty("icon"))
            {
                this.item.data = {icon:this.baseicon};
                _loc_2.visible = false;
            }
            else
            {
                this.item.data = this._data;
                _loc_2.visible = true;
            }
            this.item.changeSuperLvXY(6, 2);
            return;
        }// end function

    }
}
